Ext.require([
    'Ext.tree.*',
    'Ext.data.*',
    'Ext.layout.container.HBox',
    'Ext.dd.*',
    'Ext.window.MessageBox'
]);
Ext.onReady(function() {
	new Ext.panel.Panel ({
		renderTo:Ext.getBody(),
	    layout: 'fit',
        height:'100%',
        width:'100%',
        border: false,
        items: [attachmentView(busiId)]       
	});
});


/**
 * 附件查看
 */
function attachmentView(busiId) {
    var grid = UploadPanel.createGrid({
        busiId: busiId,//业务ID
        editable: false,//是否可以修改附件内容
        gridConfig: {
            itemId: 'window_contentForm_tab_upload_grid'
        }
    });
    //附件加载完成后计算总文件数，并写到页签上
    grid.getStore().on('load', function (self, records, successful) {
        var sum = 0;
        if (records != null) {
            for (var i = 0; i < records.length; i++) {
                if (records[i].data.STATUS == '已上传') {
                    sum++;
                }
            }
        }
        if (grid.up('tabpanel') && grid.up('tabpanel').el && grid.up('tabpanel').el.dom) {
            $(grid.up('tabpanel').el.dom).find('span.file_sum').html('(' + sum + ')');
        } else if ($('span.file_sum')) {
            $('span.file_sum').html('(' + sum + ')');
        }
    });
    return grid;
}

